import React from "react";
import { connect } from "react-redux";
import { increase, decrease } from "@/store/actions/counter";

function User({ number, onIncrease, onDecrease }) {
  return (
    <div>
      <h1>我的</h1>
      <p>
        <button onClick={onDecrease}>减少</button>
        <strong>{number}</strong>
        <button onClick={onIncrease}>增加</button>
      </p>
    </div>
  );
}

export default connect(
  (state) => ({ number: state.counter }),
  (dispatch) => ({
    onIncrease: () => dispatch(increase()),
    onDecrease: () => dispatch(decrease()),
  })
)(User);
